//Sunday, December 13 2009
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class TheLuckyNumbers
{
public:
	int count(int a, int b)
	{
		return lucky(4,a,b)+lucky(7,a,b);
	}
	int lucky(int x, int a, int b)
	{
		int r = 0;
		if(x>=a && x<=b) r++;
		if(x <= b/10) r += lucky(x*10+4,a,b)+lucky(x*10+7,a,b);
		return r;
	}
};
